package com.mes.defece.controller;

import com.mes.common.pojo.MESResult;
import com.mes.defece.service.MaterialProductsService;
import com.mes.pojo.defece.MaterialProducts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 侯伟豪
 * @Company 起点编程
 * @Description
 * @Time 2024/10/21 10:15
 */
@RestController
@CrossOrigin
@RequestMapping("/material")
public class MaterialProductsController {
    @Autowired
    private MaterialProductsService materialProductsService;
//    分页查询
    @GetMapping("selectAll")
    public Object selectAll(MaterialProducts materialProducts, Integer page, Integer limit) {
        return materialProductsService.selectAll(materialProducts, page, limit);
    }
//    新增物料产品信息
    @PostMapping("add")
    public MESResult add(@RequestBody MaterialProducts materialProducts) {
        return materialProductsService.addMaterialProducts(materialProducts);
    }
//    根据id查询物料产品信息
    @GetMapping("selectById")
    public MESResult selectById(Long materialProductId) {
        return materialProductsService.selectById(materialProductId);
    }
//    根据id修改物料产品信息
    @PostMapping("update")
    public MESResult update(@RequestBody MaterialProducts materialProducts) {
        return materialProductsService.updateMaterialProducts(materialProducts);
    }
//    根据id删除物料产品信息
    @DeleteMapping("delete")
    public MESResult delete(Long materialProductId){
        return materialProductsService.deleteMaterialProducts(materialProductId, 99);
    }
}